package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select * from user where userId=#{userId} and password=#{password}")
    public User getUserByIdByPass(User user);

    @Select("select * from user where userId=#{userId}")
    public User getUserById(String userId);

    @Insert("insert into user (userId, password, userName, userSex, userImg, delTag, usertype) values(#{userId}, #{password}, #{userName}, #{userSex}, #{userImg}, 1, #{usertype})")
    public int saveUser(User user);
    
    public int updateUserById(User user);

    @Delete("delete from user where userId=#{userId}")
    public int removeUser(User user);

    @Delete("delete from orders where userId=#{userId}")
    public int removeOrders(User user);

    @Delete("delete from cart where userId=#{userId}")
    public int removeCart(User user);

    @Delete("delete from comments where userId=#{userId}")
    public int removeComments(User user);

    @Delete("delete from deliveryaddress where userId=#{userId}")
    public int removeDeliveryaddress(User user);

}
